package licode.unisop.unilite.result;

public class UniResultCode {
    /** 成功状态码 */
    public static UniResultCode SUCCESS = new UniResultCode(200, "成功");

    /** 错误状态码 */
    public static UniResultCode PARAM_IS_INVALID = new UniResultCode(201, "参数无效");
    public static UniResultCode PARAM_IS_BLANK = new UniResultCode(202, "参数为空");
    public static UniResultCode PARAM_NOT_COMPLETE = new UniResultCode(402, "参数缺失");
    public static UniResultCode USER_NOT_LOGIN_IN = new UniResultCode(501, "用户未登录");
    public static UniResultCode USER_LOGIN_ERROR = new UniResultCode(502, "账号不存在或密码错误");
    public static UniResultCode INVALID_SERVER_ERROR = new UniResultCode(503, "服务不可用");
    public static UniResultCode SYSTEM_ERROR = new UniResultCode(500, "系统繁忙，请稍后重试");
    public static UniResultCode FORBIDDEN = new UniResultCode(401, "访问的资源不存在");
    public static UniResultCode UNAUTHORIZED = new UniResultCode(403, "用户没有权限");
    public static UniResultCode NOT_IMPLEMENTED = new UniResultCode(501, "请求功能未实现");
    public static UniResultCode BAD_REQUEST = new UniResultCode(400, "请求格式错误");

    private final Integer code;
    private final String message;

    public UniResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer code() {
        return this.code;
    }

    public String message() {
        return this.message;
    }

    public void throwBy() {
        throw new UniException(this.code, this.message);
    }

    public UniException buildThrow() {
        return new UniException(this.code, this.message);
    }
}
